# coding = UTF-8
# @Time : 2021/11/30 17:05
# @Author : PP_YY
# @File : douban_flask.py
# @Version : 0.0.1
# 用来创建flask应用

from flask import Flask,render_template,request
import sqlite3

app = Flask(__name__)

# 路由解析列表

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/index")
def go_index():
    return index()

@app.route("/movie")
def movie():
    datalist = []
    try:
        connect = sqlite3.connect("/home/Codes/python/潘猪的爬虫小学习_P/豆瓣top250.db")
        cursor = connect.cursor()
        sql = '''
        select * from movie250
        '''
        data = cursor.execute(sql)
        for item in data:
            datalist.append(item)
        connect.commit()
        cursor.close()
    except:
        print("database open fail")
    return render_template("movie.html",movies = datalist)

@app.route("/word")
def word():
    return render_template("word.html")

@app.route("/team")
def team():
    return render_template("team.html")


if __name__ == "__main__":
    app.run(host='127.0.0.1', port=8080)